#ifndef BODY_H
#define BODY_H

#include "arttracking.h"

namespace Tracking{
	


	#pragma region BodyBase
	class BodyBase
	{
	public:
		
		BodyBase(ARTTracking::BodyType type,int id);
		~BodyBase();
		
		TrackingState getTrackingState();

		int getId() { return _id; }
		ARTTracking::BodyType getBodyType() { return _bodytype; }
		float getQuality() {return _quality; }
		mat4f getTransformationMatrix();



	protected:
		/*Body-ID*/
		int _id;
		/*Tracking quality of markers (0<=_quality<=1.0, -1.0 if untracked) */
		float _quality;
		/*Type of Body (Glasses or FlyStick) */
		ARTTracking::BodyType _bodytype;
		/*Transformation Matrix of Body */
		mat4f _transformationMatrix;

		virtual void _update(const DTrack_Body_Type_d &body);

	};
	#pragma endregion BodyBase

	#pragma region Body
	class Body : public BodyBase
	{
	public:
		friend class ARTTracking;
		Body(int id);
	private:
		void _update(const DTrack_Body_Type_d &body);
	};
	#pragma endregion Body

	#pragma region FlyStick
	class FlyStick : public BodyBase
	{

	friend class ARTTracking;
	public:
		enum Button{
			TRIGGER=0,
			BUTTON1,
			BUTTON2,
			BUTTON3,
			BUTTON4
		};
		enum ButtonState {
			UNPRESSED=0,
			TRIGGERED,
			PRESSED,
			RELEASED
		};

		FlyStick(int id);
		~FlyStick(){}

		ButtonState getButtonState(Button b) { return _buttons[b]; }
		const float& getJoystickValues() { return *_joystickValue ; }

		const mat4f& getDeltaMatrix();

		const mat4f& getTest();

	private:
		/*Button-State Array */
		ButtonState _buttons[5];
		/*Joystick-Values (X,Y,0.0<=val<=1.0) */
		float _joystickValue[2];

		/*Transformation Matrix when trigger is pulled, ID elsewise */
		mat4f _triggerMatrix;
		
		mat4f _deltaMatrix;
		void _handleButtonState(int*);
		void _update(const DTrack_FlyStick_Type_d &flystick);
	};
	#pragma endregion FlyStick

}//end namespace Tracking

#endif